const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
const homeRouter = require('./routes/home')
const newsRouter = require('./routes/news')
const uploadRouter = require('./routes/upload')

const app = express();

app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
// 静态资源中间件
app.use('/static', express.static(path.join(__dirname,'public')))
// 设置模板引擎
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');


// 路由中间件定义路由
app.use(homeRouter)
app.use(newsRouter)
app.use(uploadRouter)

app.listen(3000, ()=>{
  console.log('程序启动了');
})